﻿
-- ================================================
-- Remarks: 
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'Ivy_Sys_SessionLogReport_GetByKey')
	BEGIN
		DROP  Procedure  Ivy_Sys_SessionLogReport_GetByKey
	END

GO

CREATE PROCEDURE [Ivy_Sys_SessionLogReport_GetByKey] 
-- =============================================
-- Author:		<Ram pravesh kr>
-- Create date: <06/06/2016>
-- Description:	<Ivy_Sys_SessionLogReport_GetByKey>
-- =============================================
-- Add the parameters for the stored procedure here
	(
				@SessionLogPrimaryID int
	)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT OFF;

	SELECT   [Sys_SessionLog].[SessionLogPrimaryID], 
	         [Sys_SessionLog].[UserSessionID], 
			 [Sys_SessionLog].[UserIPAddress], 
			 [Sys_SessionLog].[UserSessionStartTime], 
			 [Sys_SessionLog].[UserSessionEndTime], 
             [Sys_SessionLog].[UserBrowserName], 
			 [Person].[PersonFirstName], 
			 [Person].[PersonLastName], 
			 [Person].[PersonPrimaryEmailID], 
			 [Sys_OrganizationMaster].[OrganizationName]
   FROM      [Person] LEFT OUTER JOIN [Sys_OrganizationMaster] 
   ON        [Person].[Sys_OrganizationID] = [Sys_OrganizationMaster].[OrganizationID] RIGHT OUTER JOIN [Sys_SessionLog] 
   ON        [Person].[PersonKey] = [Sys_SessionLog].[UserKey]
   WHERE		
		(
			[Sys_SessionLog].[SessionLogPrimaryID] = @SessionLogPrimaryID
		);
	
END
GO
 